package com.itfreer.power.dao.user;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Table;

import org.springframework.beans.BeanUtils;

import com.itfreer.form.api.JdbcBaseEntity;
import com.itfreer.power.entity.user.UserAuthenticationEntity;

/**
 * 定义用户认证实体
 */
@Entity(name = "sso_user_uthentication")
@Table(indexes = { 
        @Index(name="sso_user_accounts", columnList="s_accounts", unique=true)})
public class JdbcUserAuthenticationEntity implements JdbcBaseEntity<UserAuthenticationEntity>, Serializable {
	private static final long serialVersionUID = 3065523710938752296L;

	/**
	 * 帐号
	 * 唯一值
	 */
	@Id
	@Column(name = "id", length = 50, nullable = false)
	private String userid;
	
	/**
	 * 帐号
	 */
	@Column(name = "s_accounts", length = 50, nullable = false)
	private String accounts;
	
	/**
	 * 密码
	 */
	@Column(name = "s_password", length = 50, nullable = false)
	private String password;
	
	/**
	 * 是否有效
	 */
	@Column(name = "is_valid", nullable = false)
	private Boolean valid = null;

	/**
	 * 帐号
	 */
	public String getUserid() {
		return userid;
	}

	/**
	 * 帐号
	 */
	public void setUserid(String userid) {
		this.userid = userid;
	}
	
	/**
	 * 帐号
	 */
	public String getAccounts() {
		return accounts;
	}

	/**
	 * 帐号
	 */
	public void setAccounts(String accounts) {
		this.accounts = accounts;
	}

	/**
	 * 密码
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * 密码
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * 是否有效
	 */
	public Boolean getValid() {
		return valid;
	}

	/**
	 * 是否有效
	 */
	public void setValid(Boolean isValid) {
		this.valid = isValid;
	}
	
	@Override
	public void setId(String id) {
		setUserid(id);
	}

	@Override
	public void from(UserAuthenticationEntity t) {
		BeanUtils.copyProperties(t, this);
	}

	@Override
	public UserAuthenticationEntity toEntity() {
		UserAuthenticationEntity toEntity = new UserAuthenticationEntity();
		BeanUtils.copyProperties(this, toEntity);
		return toEntity;
	}
}
